package com.bwie.interrogation.service.impl;

import com.bwie.common.security.utils.SecurityUtils;
import com.bwie.interrogation.domain.dto.AddReviewDTO;
import com.bwie.interrogation.mapper.MedPatientEvaluateMapper;
import com.bwie.interrogation.service.MedPatientEvaluateService;
import com.bwie.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MedPatientEvaluateServiceImplMedPatient implements MedPatientEvaluateService {
    /**
     * 注入
     */
    @Autowired
    private MedPatientEvaluateMapper mapper;

    /**
     * 患者添加评论
     * @param addReviewDTO
     */
    @Override
    public void medAddReview(AddReviewDTO addReviewDTO) {
        //获取登录用户
        LoginUser loginUser = SecurityUtils.getLoginUser();
        //患者添加评论
        Integer i = mapper.medAddReview(loginUser.getUserid(),addReviewDTO);
        //判断是否添加成功
        if (i<=0){
            //抛出异常
            throw new RuntimeException("评论失败");
        }
    }
}
